﻿using System;
using System.Data.Common;
using System.Data;


namespace E2_WEBSITE.Code.Admin
{
    public class NewsInfo
    {
        public int ID { get; set; }
        public string Title { get; set; }
        public string Content { get; set; }
        public int UserId { get; set; }
        public DateTime PublishDay { get; set; }

        public NewsInfo()
        { }

        public NewsInfo(string title, string content, int user, DateTime pubDay)
        {
            this.Title = title;
            this.Content = content;
            this.UserId = user;
            this.PublishDay = pubDay;
        }

        static public NewsInfo Load(DataTable data)
        {
            NewsInfo news = new NewsInfo(
                data.Rows[0]["TieuDe"].ToString(),
                data.Rows[0]["NoiDung"].ToString(),
                int.Parse(data.Rows[0]["idNguoiDung"].ToString()),
                DateTime.ParseExact(data.Rows[0]["NgayDang"].ToString(), "MM/dd/yyyy hh:mm:ss tt", null));

            news.ID = int.Parse(data.Rows[0]["ID"].ToString());
            return news;
        }
    }
}
